Message Composition And Templates
This document explains the message composition and templating functionality for WhatsApp bulk messaging. It covers the editing interface, personalization using {{name}} placeholders, validation and limits, dynamic content generation, preview and character counting, and best practices for crafting engaging messages while complying with platform guidelines.
The message composition and templating features span the Electron front-end (React components and IPC), the Electron main process (WhatsApp client orchestration), and optional Python utilities for contact parsing and validation.
Message editor UI"] BL["BulkMailer.jsx
State & actions"] PY["pyodide.js
Python bridge"] end subgraph "Electron Main Process" PRE["preload.js
IPC exposure"] MAIN["main.js
WhatsApp client & messaging"] end subgraph "Python Backend" PYN["parse_manual_numbers.py
Manual number parsing"] APP["app.py
Contact processing routes"] end UI_WA --> BL BL --> PRE PRE --> MAIN BL --> PY PY --> PYN BL --> APP
Diagram sources
Section sources
Message editor UI with character counter and personalization hint
Template engine: placeholder replacement with contact data
Validation and limits: message length and contact parsing
Preview and feedback: real-time status and logs
Optional Python utilities for manual number parsing and validation
Key capabilities:
Personalization using {{name}} placeholders
Character limit display (4096 characters)
Dynamic content generation per contact
Real-time status updates and logs
Section sources
The message composition flow integrates UI input, state management, IPC to the main process, and the WhatsApp client. The main process performs personalization and sends messages, reporting status back to the UI.
Diagram sources
Message Editor UI#
Text area for composing messages with a placeholder indicating {{name}} personalization
Character counter showing current length vs. the 4096-character limit
Disabled state during sending to prevent concurrent edits
Send button triggers the bulk send action
Diagram sources
Section sources
Template Engine and Personalization#
The main process replaces {{name}} with either the contact’s name or a default fallback (“Friend”) before sending
Chat ID construction uses the contact number with WhatsApp’s c.us format
Unregistered numbers are detected and reported as failures
Diagram sources
Section sources
Message Validation and Limits#
Character limit: 4096 characters shown in the editor
Message presence: send is disabled if the message is empty
Contact presence: send is disabled if no contacts are loaded
During sending, the UI disables controls to prevent interruptions
Diagram sources
Section sources
Contact Data and Manual Parsing#
Manual number parsing supports formats with optional names and multiple separators
The Electron main process can import CSV/Text files for contacts
Optional Python utilities provide additional parsing and validation logic
Diagram sources
Section sources
Message Preview and Feedback#
Real-time status updates (connecting, ready, authenticated, errors)
Activity log displays send results with color-coded indicators
QR code display and retry mechanism for connection issues
Diagram sources
Section sources
UI depends on BulkMailer for state and actions
BulkMailer bridges UI to Electron IPC exposed in preload.js
Preload.js invokes main.js handlers for WhatsApp operations
Manual number parsing uses pyodide.js to run Python code in the renderer
Optional Python backend routes support file uploads and validation
Diagram sources
Section sources
Rate limiting: The main process waits between sending messages to avoid rate limits and reduce spam risk
Batch size: Consider splitting large contact lists into smaller batches
Network stability: Ensure reliable connectivity; QR loading and authentication retries are handled
UI responsiveness: Disable send controls during operations to prevent duplicate submissions
[No sources needed since this section provides general guidance]
Common issues and resolutions:
QR code not loading: Retry connection or check console for errors
Authentication failures: Re-scan QR and ensure device permissions
Send failures: Check registration status; unregistered numbers will fail
Empty message or no contacts: Ensure message is present and contacts are imported
Exceeding character limit: Trim message to under 4096 characters
Section sources
The message composition and templating system provides a robust, user-friendly interface for creating personalized WhatsApp messages at scale. With {{name}} placeholders, a clear character counter, and real-time feedback, users can craft engaging messages while respecting platform limits and best practices. The integration with Electron IPC and optional Python utilities ensures flexible contact processing and validation.